<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
// 水球图
import 'echarts-liquidfill'

const people = ref('2169080')

const echartsRef = ref()

onMounted(() => {
  let myCharts = echarts.init(echartsRef.value)

  // 设置实例
  myCharts.setOption({
    // 标题
    // title: {
    //   text: '水球图'
    // },
    // x | y轴
    xAxis: {},
    yAxis: {},
    // 系列：决定展示什么图形
    series: {
      type: 'liquidFill', // 系列
      data: [0.6, 0.4, 0.2], // 展示数据
      waveAnimation: true, // 是否展示动画
      animationDuration: 3,
      animationDurationUpdate: 0,
      radius: '100%', // 半径
      // 外边框
      outline: {
        show: true,
        borderDistance: 8,
        itemStyle: {
          color: 'none',
          borderWidth: 8,
          shadowBlur: 20,
          shadowColor: 'rgba(0,0,0,.25)'
        }
      }
    },
    // 布局组合：
    grid: {
      left: 0,
      right: 0,
      top: 0,
      bottom: 0,
    }
  })
})
</script>

<template>
  <div class="tourist">
    <div class="top">
      <p class="title">实时游客统计</p>
      <p class="bg"></p>
      <p class="right">可预约总量<span>0000</span>人</p>
    </div>

    <div class="number">
      <span v-for="(item, index) in people" :key="index">{{ item }}</span>
    </div>

    <!-- echarts展示 -->
    <div class="charts" ref="echartsRef"></div>
  </div>
</template>

<style lang="scss" scoped>
.tourist {
  height: 100%;
  width: 100%;
  background: url('../../images/dataScreen-main-lb.png') no-repeat;
  background-size: 100% 100%;
  margin-top: 10px;

  .top {
    margin-left: 20px;
    color: #fff;
    overflow: hidden;
    font-size: 20px;

    .bg {
      width: 68px;
      height: 7px;
      background: url('../../images/dataScreen-title.png') no-repeat;
      background-size: 100%;
      margin-top: 10px;
    }

    .right {
      text-align: right;

      span {
        color: yellowgreen;
      }
    }
  }

  .number {
    display: flex;
    margin-top: 30px;
    padding: 10px;
    box-sizing: border-box;

    span {
      flex: 1;
      height: 70px;
      line-height: 70px;
      text-align: center;
      background: url('../../images/total.png') no-repeat;
      background-size: 100%;
      color: #fff;
      font-size: 30px;
    }
  }

  .charts {
    width: 100%;
    height: 250px;
  }
}
</style>